import Vue from 'vue';
// 注册一个全局自定义指令 `v-perm`  v-perm="department:deleteById"
Vue.directive('perm', {
    // 当被绑定的元素插入到 DOM 中时……
    inserted: (el, binding, vnode) => {
        const value = binding.value;// department:deleteById
        let permissions = localStorage.getItem('permissions');//获取出用户所拥有的所有权限
        if (permissions){
            let auths = JSON.parse(permissions);
            if (auths && auths.join(",").indexOf(value)==-1) {//经过这个代码auths.join(",")=>"systemDictionaryItem:delete","department:list","menu:list","menu:delete","menu:save"
                el.parentNode.removeChild(el);
            }
        }
    }
});